package com.bstek.bdf4.demo;

import org.hibernate.cfg.Environment;
import org.springframework.orm.jpa.vendor.Database;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;

import java.util.HashMap;
import java.util.Map;

public class JpaUtil {

    /**
     * 设置hibernate的属性
     * @return
     */
    public static HibernateJpaVendorAdapter getHibernateJpaVendorAdapter(Database database){
        HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        vendorAdapter.setGenerateDdl(false);
        vendorAdapter.setShowSql(true);
        vendorAdapter.setDatabase(database);
       // vendorAdapter.setDatabasePlatform("org.hibernate.dialect.Oracle8iDialect");
       //  vendorAdapter.setGenerateDdl(true);
        return vendorAdapter;
    }

    /**
     * 设置hibernate的属性
     * @return
     */
    public static Map<String, Object> getJpaPropertyMap(){
        Map<String, Object> properties = new HashMap<>(1);
        properties.put(Environment.FORMAT_SQL,true);
        return properties;
    }
}